package com.ruoyi.reunion.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.reunion.domain.Venue;
import com.ruoyi.reunion.service.IVenueService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场地Controller
 * 
 * @author ccccc
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/reunion/venue")
public class VenueController extends BaseController
{
    @Autowired
    private IVenueService venueService;



    //查询所有场地
    @GetMapping("/getAllVenue")
    public AjaxResult getAllVenue(){
        List<Venue> venueList = venueService.selectVenueList(new Venue());
        return success(venueList);
    }
    



    /**
     * 查询场地列表
     */
    @PreAuthorize("@ss.hasPermi('reunion:venue:list')")
    @GetMapping("/list")
    public TableDataInfo list(Venue venue)
    {
        startPage();
        List<Venue> list = venueService.selectVenueList(venue);
        return getDataTable(list);
    }

    /**
     * 导出场地列表
     */
    @PreAuthorize("@ss.hasPermi('reunion:venue:export')")
    @Log(title = "场地", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Venue venue)
    {
        List<Venue> list = venueService.selectVenueList(venue);
        ExcelUtil<Venue> util = new ExcelUtil<Venue>(Venue.class);
        util.exportExcel(response, list, "场地数据");
    }

    /**
     * 获取场地详细信息
     */
    @PreAuthorize("@ss.hasPermi('reunion:venue:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(venueService.selectVenueById(id));
    }

    /**
     * 新增场地
     */
    @PreAuthorize("@ss.hasPermi('reunion:venue:add')")
    @Log(title = "场地", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Venue venue)
    {
        return toAjax(venueService.insertVenue(venue));
    }

    /**
     * 修改场地
     */
    @PreAuthorize("@ss.hasPermi('reunion:venue:edit')")
    @Log(title = "场地", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Venue venue)
    {
        return toAjax(venueService.updateVenue(venue));
    }

    /**
     * 删除场地
     */
    @PreAuthorize("@ss.hasPermi('reunion:venue:remove')")
    @Log(title = "场地", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(venueService.deleteVenueByIds(ids));
    }
}
